package cn.tedu.property_management_system.service.Impl;


import cn.tedu.property_management_system.entity.Property;
import cn.tedu.property_management_system.mapper.PropertyMapper;
import cn.tedu.property_management_system.service.IPropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
@Service
public class PropertyServiceImpl implements IPropertyService {
    @Autowired
    PropertyMapper mapper;
    public void insert(@RequestBody Property property){
        mapper.insert(property);
    }

    public List<Property> select(){
        return mapper.select();
    }

    public List<Property> searchSelect(@RequestBody Property property){
        return mapper.searchSelect(property);
    }

    public List<Property> searchSelects(@RequestBody Property property){
        return mapper.searchSelects(property);
    }

    public void update(@RequestBody Property property){
        mapper.update(property);
    }

    public void delete(@RequestBody Property property){
        mapper.delete(property.getId());
    }
    public int deletes(@RequestBody List<Property> list){

        if (list.size()>0) {
            for (Property property : list) {
                mapper.delete(property.getId());
            }
            return 1;
        }else {
            return 2;
        }
    }
}
